using System.Collections;
using Microsoft.Xna.Framework;
using RebEngine.GameComponents;

namespace RebEngine.Managers
{
    public class CameraManager : GameComponent
    {
        private static Hashtable _cameras = new Hashtable();
        private static bool _initialized = false;
        private static Camera _activeCamera;

        public enum CameraNumber
        {
            _default = 1,
            _dolly = 2,
            _3 = 3,
            _4 = 4,
            _5 = 5,
            _6 = 6,
            _7 = 7,
            _8 = 8,
            _9 = 9,
            _10 = 10
        }
        public static bool Initialized
        {
            get { return _initialized; }
        }
        public static Camera ActiveCamera
        {
            get { return _activeCamera; }
        }


        public CameraManager(Game game)
            : base(game)
        {
            Enabled = true;
        }
        
        public override void Initialize()
        {
            base.Initialize();

            AddCamera(new Camera(), CameraNumber._default);
            SetActiveCamera(CameraNumber._default);
            AddCamera(new Camera(), CameraNumber._dolly);

            _initialized = true;
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            _activeCamera.Update();
        }

        public static void AddCamera(Camera newCamera, CameraNumber cameraNumber)
        {
            if (!_cameras.Contains(cameraNumber))
            {
                _cameras.Add(cameraNumber, newCamera);
            }
        }

        public static void SetActiveCamera(CameraNumber cameraNumber)
        {
            if (_cameras.ContainsKey(cameraNumber))
            {
                _activeCamera = _cameras[cameraNumber] as Camera;
            }
        }
    }
}
